﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Linq;
using VehicleManagement.Codes;
using VehicleManagement.Models;

namespace VehicleManagement.Controllers
{
    public class TrackController : Controller
    {
        //
        // GET: /Track/Details/5

        public ActionResult Details(int id)
        {
            Table<Track> tracks = VehicleManagementDataContextManager.Instance.GetTable<Track>();
            Track track = tracks.Single(t => t.TrackID == id);
            return View(track);
        }


        //
        // POST: /Track/Points

        [HttpPost]
        public ActionResult Points(int id)
        {
            Table<TrackPoint> points = VehicleManagementDataContextManager.Instance.GetTable<TrackPoint>();
            var result = from point in points
                         where point.TrackID == id
                         select point;
            return Json(result.ToList<TrackPoint>());
        }

    }
}
